﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using IAC_2013.com.iac.util;
using System.Text.RegularExpressions;

namespace IAC_2013.Forms
{
    public partial class frmBaseUnit : Form
    {
        public frmBaseUnit()
        {
            InitializeComponent();
        }

        private void txtBasePhone_TextChanged(object sender, EventArgs e)
        {
            txtBasePhone.Text = ValidateUtils.checkNum(txtBasePhone.Text);
        }

        private void txtBaseFax_TextChanged(object sender, EventArgs e)
        {
            txtBaseFax.Text = ValidateUtils.checkNum(txtBaseFax.Text);
        }

        private void txtBankAccount_TextChanged(object sender, EventArgs e)
        {
            txtBankAccount.Text = ValidateUtils.checkNum(txtBankAccount.Text);
        }

        private void txtTaxCode_TextChanged(object sender, EventArgs e)
        {
            txtTaxCode.Text = ValidateUtils.checkNum(txtTaxCode.Text);
        }

        private void txtUserPhone_TextChanged(object sender, EventArgs e)
        {
            txtUserPhone.Text = ValidateUtils.checkNum(txtUserPhone.Text);
        }

        private void txtUserEmail_TextChanged(object sender, EventArgs e)
        {
            Regex regex;
            regex = new Regex(@"^[\w-]+@([\w- ]+\.)+[\w-]+$");
            ErrorProvider error = new ErrorProvider();
            Control ctrl = (Control)sender;
            if (regex.IsMatch(ctrl.Text))
            {
                error.SetError(ctrl, "");
            }
            else
            {
                error.SetError(ctrl, "Không đúng định dạng Email!");
            }
        }

        private void txtBaseEmail_TextChanged(object sender, EventArgs e)
        {
            Regex regex;
            regex = new Regex(@"^[\w-]+@([\w- ]+\.)+[\w-]+$");
            ErrorProvider error = new ErrorProvider();
            Control ctrl = (Control)sender;
            if (regex.IsMatch(ctrl.Text))
            {
                error.SetError(ctrl, "");
            }
            else
            {
                error.SetError(ctrl, "Không đúng định dạng Email");
            }
        }
    }
}
